﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        body, div, li, ul
        {
            border: 0;
            margin: 0;
            padding: 0;
            list-style-type: none;
        }
        body
        {
            background-color: #D9DFE3;
        }
        .act_container
        {
            width: 920px;
            height: 580px;
            margin: 0 auto;
            background-color: #fff;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            border-radius: 5px;
            -moz-box-shadow: 0px 0px 20px #333333;
            -webkit-box-shadow: 0px 0px 20px #333333;
            box-shadow: 0px 0px 20px #333333;
        }
        
        .act_progress
        {
            width: 880px;
            height: 60px;
            margin-left: 20px;
            background-color: #fff;
        }
        /*---act_title  */
        .act_title
        {
            width: 880px;
            height: 38px;
            margin-left: 20px;
            background-color: #BEC9CC;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            border-radius: 5px;
            background: -moz-linear-gradient(#E2E6ED, #B6C3C6);
            background: -webkit-linear-gradient(#E2E6ED, #B6C3C6);
            background: -ms-linear-gradient(#E2E6ED, #B6C3C6); /*For IE10*/
            background: linear-gradient(#E2E6ED, #B6C3C6);
        }
        
        .act_title div
        {
            float: left;
        }
        .act_title .act_name
        {
            font-size: 18px;
            font-family: Lucida Sans;
            line-height: 38px;
            margin-left: 20px;
            color: #5D5E5F;
            font-weight: bold;
        }
        
        .act_title .act_description
        {
            font-size: 15px;
            font-family: Lucida Sans;
            line-height: 38px;
            color: #555656;
            font-weight: bold;
        }
        
        
        /*---act_content  */
        .act_content
        {
            width: 880px;
            height: 385px;
            background-color: #F1F3F5;
            margin-left: 20px;
            margin-top: 10px;
            overflow: hidden;
            -moz-border-radius: 8px;
            -webkit-border-radius: 8px;
            border-radius: 8px;
        }
        
        .act_sequen_container
        {
            width: 870px;
            height: 90px;
            padding-left: 10px;
            margin-top: 15px;
        }
        .act_sequen_placeholder
        {
            width: 135px;
            height: 90px;
            float: left;
            margin-right: 10px;
            background-color: #D8DEE2;
            border-spacing: 0px;
            z-index: -1;
            -moz-box-shadow: inset 0px 0px 5px #9B9C9D;
            -webkit-box-shadow: inset 0px 0px 5px #9B9C9D;
            box-shadow: inset 0px 0px 5px #9B9C9D;
        }
        .act_sequen_placeholder .sequen_num
        {
            width: 135px;
            height: 90px;
            text-align: center;
            vertical-align: middle;
            font-size: 75px;
            color: #CAD2D7;
            font-family: Lucida Sans;
            font-weight: bold;
            position: absolute;
        }
        
        
        .act_drag_container
        {
            width: 860px;
            height: 270px;
            margin-top: 10px;
            margin-right: 10px;
            margin-left: 10px;
            position: relative;
        }
        
        .act_drag_box
        {
            width: 188px;
            height: 130px;
            background-color: #fff;
            overflow: auto;
            float: left;
            -moz-box-shadow: 0px 0px 20px #333333;
            -webkit-box-shadow: 0px 0px 20px #333333;
            box-shadow: 0px 0px 20px #333333;
            z-index: 10;
        }
        .act_drag_box hover
        {
        }
        
        .act_img_box
        {
            width: 158px;
            height: 104px;
            margin-top: 13px;
            margin-left: 15px;
            background-color: #BBBDBF;
            background-image: url(http://cnshhq-0187:88/images/image_5.gif);
        }
        
        #draggable_1
        {
            left: 30px; /*top: 149px;*/
            top: 24px;
            -moz-transform: rotate(-10deg);
            -webkit-transform: rotate(-10deg);
            -ms-transform: rotate(-10deg);
            transform: rotate(-10deg);
            position: absolute;
        }
        
        #draggable_2
        {
            left: 109px; /*top: 239px;*/
            top: 114px;
            -moz-transform: rotate(10deg);
            -webkit-transform: rotate(10deg);
            -ms-transform: rotate(10deg);
            transform: rotate(10deg);
            position: absolute;
        }
        
        #draggable_3
        {
            left: 328px;
            top: 25px;
            -moz-transform: rotate(10deg);
            -webkit-transform: rotate(10deg);
            -ms-transform: rotate(10deg);
            transform: rotate(10deg);
            position: absolute;
        }
        
        #draggable_4
        {
            left: 464px; /*top: 198px;*/
            top: 73px;
            -moz-transform: rotate(-10deg);
            -webkit-transform: rotate(-10deg);
            -ms-transform: rotate(-10deg);
            transform: rotate(-10deg);
            position: absolute;
        }
        
        #draggable_5
        {
            left: 664px;
            top: 20px; /*top: 145px;*/
            -moz-transform: rotate(10deg);
            -webkit-transform: rotate(10deg);
            -ms-transform: rotate(10deg);
            transform: rotate(10deg);
            position: absolute;
        }
        
        #draggable_6
        {
            left: 645px;
            top: 132px; /*top: 275px;*/
            -moz-transform: rotate(-2deg);
            -webkit-transform: rotate(-2deg);
            -ms-transform: rotate(-2deg);
            transform: rotate(-2deg);
            position: absolute;
        }
        .ui_state_active
        {
            -moz-box-shadow: 0px 0px 20px #555;
            -webkit-box-shadow: 0px 0px 20px #555;
            box-shadow: 0px 0px 20px #555;
        }
        .ui_state_hover
        {
            -moz-box-shadow: 0px 0px 20px #55B147;
            -webkit-box-shadow: 0px 0px 20px #55B147;
            box-shadow: 0px 0px 20px #55B147;
        }
        .btn_ok
        {
            background-image: url('ok_btn.png');
            background-repeat: no-repeat;
            width: 86px;
            height: 86px; /*position: absolute;
            bottom: 0px;*/
            position: relative;
            margin: 0 auto;
            top: 194px;
            cursor: pointer;
        }
        
        .act_img_box_border
        {
            border: 4px solid white;
            width: 158px;
            height: 104px;
            position: absolute;
            top: 12px;
            left: 14px;
        }
    </style>
    <script src="jquery-ui-1.9.0.custom/js/jquery-1.8.2.js" type="text/javascript"></script>
    <script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js" type="text/javascript"></script>
</head>
<body>
    <div class="act_container">
        <div class="act_progress">
        </div>
        <div class="act_title">
            <div class="act_name">
                Activty 1
            </div>
            <div class="act_description">
                - Fill in the Mind Map
            </div>
        </div>
        <div class="act_content">
            <div class="act_sequen_container">
                <div class="act_sequen_placeholder">
                    <div class="sequen_num">
                        1</div>
                </div>
                <div class="act_sequen_placeholder">
                    <div class="sequen_num">
                        2</div>
                </div>
                <div class="act_sequen_placeholder">
                    <div class="sequen_num">
                        3</div>
                </div>
                <div class="act_sequen_placeholder">
                    <div class="sequen_num">
                        4</div>
                </div>
                <div class="act_sequen_placeholder">
                    <div class="sequen_num">
                        5</div>
                </div>
                <div class="act_sequen_placeholder">
                    <div class="sequen_num">
                        6</div>
                </div>
            </div>
            <div class="act_drag_container">
                <div id="draggable_1">
                    <div class="act_drag_box" parent="draggable_1">
                        <div class="act_img_box">
                        </div>
                    </div>
                </div>
                <div id="draggable_2">
                    <div class="act_drag_box" parent="draggable_2">
                        <div class="act_img_box">
                        </div>
                    </div>
                </div>
                <div id="draggable_3">
                    <div class="act_drag_box" parent="draggable_3">
                        <div class="act_img_box">
                        </div>
                    </div>
                </div>
                <div id="draggable_4">
                    <div class="act_drag_box" parent="draggable_4">
                        <div class="act_img_box">
                        </div>
                    </div>
                </div>
                <div id="draggable_5">
                    <div class="act_drag_box" parent="draggable_5">
                        <div class="act_img_box">
                            5
                        </div>
                    </div>
                </div>
                <div id="draggable_6">
                    <div class="act_drag_box" parent="draggable_6">
                        <div class="act_img_box">
                            6
                        </div>
                    </div>
                </div>
                <div class="btn_ok">
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">


        $(".act_drag_box").hover(function () { $(this).css("cursor", "move"); });
        $(".act_drag_box").draggable({
            revert: true,
            revertDuration: "300",
            containment: "act_content",
            zIndex: 101,
            drag: function (event, ui) {
                $(this).css("cursor", "move");

                var parent = $("#" + $(this).attr("parent"));
                parent.css({ "z-index": "100" });
                //1. set transform none
                if (parent.css('transform') != 'matrix(1, 0, 0, 1, 0, 0)') {
                    parent.data("transform", parent.css('transform'));
                    var transform = 'matrix(1, 0, 0, 1, 0, 0)';

                    parent.css({ '-webkit-transform': transform });
                    parent.css({ '-moz-transform': transform });
                    parent.css({ '-ms-transform': transform });
                    parent.css({ 'transform': transform });
                }

            },
            stop: function (event, ui) {
                $(this).css("cursor", "default");

                var parent = $("#" + $(this).attr("parent"));
                parent.css({ "z-index": "auto" });

                var transform = parent.data("transform");
                parent.css({ '-webkit-transform': transform });
                parent.css({ '-moz-transform': transform });
                parent.css({ '-ms-transform': transform });
                parent.css({ 'transform': transform });

            }
        });


        $(".act_sequen_placeholder").droppable({
            tolerance: "pointer",
            drop: function (event, ui) {

                //change position
                if ($(this).find(".act_drag_box").length == 1) {

                    var children = $(this).find(".act_drag_box");
                    var children_clone = children.clone();
                    var offset_child = calcOffset(children.offset(), ui.draggable.parent().offset());
                    var offset_drag = calcOffset(ui.draggable.offset(), $(this).offset());

                    // b to s
                    if (ui.draggable.css("width") == "188px") {

                        var $parent = $("#" + children.attr("parent"));
                        var offset = calcOffset(children.offset(), $parent.offset());

                        children.appendTo($parent);
                        children.css(offset);

                        children.css({ "width": "188px", "height": "130px" });
                        children.find(".act_img_box")
                                .css({ "left": "0px", "top": "0px" })
                                .css({ "width": "158px", "height": "104px" })
                                .css({ "margin-top": "13px", "margin-left": "15px" });

                        $(".act_drag_box").draggable('disable');
                        children.animate({ "left": "0px", "top": "0px" }, 1000, "easeOutBounce", function () {
                            $(".act_drag_box").draggable('enable');
                        });

                    } else {
                        children.appendTo(ui.draggable.parent());
                        //s to s
                        children.css(offset_child);
                        children.find(".act_img_box")
                        .css({ "left": "0px", "top": "0px" })
                        .css({ "width": ui.draggable.find(".act_img_box").width() })
                        .css({ "height": ui.draggable.find(".act_img_box").height() })
                        .css({ "margin-top": ui.draggable.find(".act_img_box").css("margin-top"), "margin-left": ui.draggable.find(".act_img_box").css("margin-left") });
                        children.css({ "width": ui.draggable.width(), "height": ui.draggable.height() });


                        $(".act_drag_box").draggable('disable');
                        children.animate({ "left": "0", "top": "0" }, 300, function () {
                            $(".act_drag_box").draggable('enable');
                        });
                    }
                    ui.draggable.appendTo(this);


                    ui.draggable.css(offset_drag);
                    ui.draggable.find(".act_img_box")
                        .css({ "left": "0px", "top": "0px" })
                        .css({ "width": children_clone.find(".act_img_box").width() })
                        .css({ "height": children_clone.find(".act_img_box").height() })
                        .css({ "margin-top": children_clone.find(".act_img_box").css("margin-top"), "margin-left": children_clone.find(".act_img_box").css("margin-left") });
                    ui.draggable.css({ "width": children_clone.width(), "height": children_clone.height() });

                    ui.draggable.animate({ "left": "0", "top": "0" }, 300);
                    return;
                }

                var offset = calcOffset(ui.draggable.offset(), $(this).offset());
                ui.draggable.appendTo(this);
                ui.draggable.css(offset);
                ui.draggable.find(".act_img_box")
                    .css({ "left": "0px", "top": "0px" })
                    .css({ "width": "135px", "height": "90px" })
                    .css({ "margin-top": "0", "margin-left": "0" });
                ui.draggable.css({ "width": "135px", "height": "90px" });

                ui.draggable.animate({ "left": "0px", "top": "0px" }, 300, "easeOutBounce");

            },
            activeClass: "ui_state_active",
            hoverClass: "ui_state_hover"
        });

        $(".act_drag_container").droppable({
            tolerance: "pointer",
            drop: function (event, ui) {
                //2. reset transform
                var parent = $("#" + ui.draggable.attr("parent"));
                var transform = parent.data("transform");
                if (transform == 'matrix(1, 0, 0, 1, 0, 0)') {
                    parent.css({ '-webkit-transform': transform });
                    parent.css({ '-moz-transform': transform });
                    parent.css({ '-ms-transform': transform });
                    parent.css({ 'transform': transform });
                }

                if (ui.draggable.parent().hasClass("act_sequen_placeholder") == false)
                    return;

                var $parent = $("#" + ui.draggable.attr("parent"));
                var offset = calcOffset(ui.draggable.offset(), $parent.offset());

                ui.draggable.appendTo($parent);
                ui.draggable.css(offset);
                ui.draggable.find(".act_img_box")
                    .css({ "left": "0px", "top": "0px" })
                    .css({ "width": "158px", "height": "104px" })
                    .css({ "margin-top": "13px", "margin-left": "15px" });
                ui.draggable.css({ "width": "188px", "height": "130px" });

                ui.draggable.animate({ "left": "0px", "top": "0px" }, 1000, "easeOutBounce");
            }
        });
        function calcOffset(setA, setB) {
            return {
                "left": parseInt(setA.left - setB.left, 10),
                "top": parseInt(setA.top - setB.top, 10)
            }
        }
        
        
    </script>
</body>
</html>
